-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Add PeekMut::pop #38733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PeekMut::pop #38733
Conversation
Sounds reasonable to me! Could you add a comment on the struct definition of |
Or better yet I wouldn't mind a boolean flag to manage this. |
A fairly common workflow is to put a bunch of stuff into a binary heap and then mutate the top value until its empty. This both makes that a bit more convenient (no need to save a boolean off and pop after to avoid borrowck issues), and a bit more efficient since you only shift once.
Updated |
Alright let's merge! @sfackler r=me with a tracking issue updated |
@bors r=alexcrichton |
📌 Commit 54dc533 has been approved by |
⌛ Testing commit 54dc533 with merge b97b605... |
Add PeekMut::pop A fairly common workflow is to put a bunch of stuff into a binary heap and then mutate the top value until its empty. This both makes that a bit more convenient (no need to save a boolean off and pop after to avoid borrowck issues), and a bit more efficient since you only shift once. r? @alexcrichton cc @rust-lang/libs
☀️ Test successful - status-appveyor, status-travis |
Any reason for making it a static function instead of a member function that takes Self? The later is shorter and doesn't require importing. |
|
Got it, thanks. |
A fairly common workflow is to put a bunch of stuff into a binary heap
and then mutate the top value until its empty. This both makes that a
bit more convenient (no need to save a boolean off and pop after to
avoid borrowck issues), and a bit more efficient since you only shift
once.
r? @alexcrichton
cc @rust-lang/libs